package simplecoder.domain.jsp;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import simplecoder.domain.Module;
import simplecoder.domain.Pojo;

public abstract class Page {

	protected Pojo pojo;
	protected Module module;
	protected Map<String, Object> params;
	
	public void init(Module module){
		this.module = module;
		pojo = module.getPojo();
		params = new HashMap<String, Object>();
		params.put("pojoInstanceName", StringUtils.uncapitalize(pojo.getName()));
		init();
	}
	
	public Map<String, Object> getParams() {
		params.put("moduleTitle", this.module.getTitle());
		params.put("fieldList", pojo.getFieldList());
		return params;
	}
	
	public String getPath(){
		return pojo.getName();
	}
	
	public String getName(){
		return getSuffix()+".jsp";
	}
	
	protected abstract void init();
	
	public abstract String getSuffix();
	
}
